﻿using MDT.LifeSewagePlatform.Conmmon;
using MDT.LifeSewagePlatform.Mysql;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.IRepository
{
    public interface IBaseRepository<TEntity> where TEntity : BaseEntity
    {
        public IMysqlDBBase _dbContext { get; set; }

        public int GetCount();
        
        public   ValueTask<EntityEntry<TEntity>> Create(TEntity entity, int CreatorId);
       

        public   Task<List<TEntity>> Create(List<TEntity> entitys, int CreatorId);
        

        public  Task<EntityEntry<TEntity>> Update(TEntity entity, int updateid);
        
        public   Task Update(List<TEntity> entitys, int updateid);
       
        public  Task Delete(Expression<Func<TEntity, bool>> lamada);
        public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> lamada);
        public Task SoftDelete(Expression<Func<TEntity, bool>> lamada, int deleterId);
        
        public Task<bool> AnyAsync(Expression<Func<TEntity, bool>> lamada);
        public IQueryable<TEntity> GetQuery();

        /// <summary>
        /// 如果不存在返回为空
        /// </summary>
        /// <param name="lamada"></param>
        /// <returns></returns>

        public  Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> lamada);
       
        public  Task<bool> SaveChangesAsync();
       
        public bool SaveChanges();
        
    }
}
